<template>
	<view>
		<myhead left="1" txt="功能测试"></myhead>
		<view class="inputList" style="margin-top: 10vw;">
		    <view class="title">银行</view>
		    <input placeholder="选择银行" v-model="stateTxt" @tap="xzBtn" disabled="disabled"></input>
		</view>
		<view class="inputList">
		    <view class="title">卡号</view>
		    <input placeholder="请输入卡号" v-model="kaNum"></input>
		</view>
		<view class="btn" @tap="btn">保存</view>
	</view>
</template>

<script>
	const http = require('../../utils/http.js');
	export default {
		data() {
			return {
				stateTxt:'',
				bankCode:'',
				kaNum:null
			}
		},
		onLoad(options) {
			
		},
		onShow() {
			
		},
		methods: {
			bindDateChange: function(e) {
				this.myDate = e.target.value
			},
			xzBtn:function(){
				let that=this
				uni.showActionSheet({
				    itemList: ['农业银行', '建设银行', '中国银行', '浦发银行', '中信银行', '工商银行', '交通银行'],
				    success: function (res) {
				        //console.log('选中了第' + (res.tapIndex + 1) + '个按钮');
						that.state=res.tapIndex
						if(res.tapIndex==0){
							that.stateTxt='农业银行'
							that.bankCode=1003
						}
						if(res.tapIndex==1){
							that.stateTxt='建设银行'
							that.bankCode=1002
						}
						if(res.tapIndex==2){
							that.stateTxt='中国银行'
							that.bankCode=1001
						}
						if(res.tapIndex==3){
							that.stateTxt='浦发银行'
							that.bankCode=1004
						}
						if(res.tapIndex==4){
							that.stateTxt='中信银行'
							that.bankCode=1005
						}
						if(res.tapIndex==5){
							that.stateTxt='工商银行'
							that.bankCode=1006
						}
						if(res.tapIndex==6){
							that.stateTxt='交通银行'
							that.bankCode=1007
						}
				    },
				    fail: function (res) {
				        console.log(res.errMsg);
				    }
				});
			},
			btn:function(){
				if(!this.stateTxt){
					uni.showToast({
					  title: '请选择银行',
					  icon: 'none'
					});
					return false
				}
				if(!this.kaNum){
					uni.showToast({
					  title: '请输入金额',
					  icon: 'none'
					});
					return false
				}
				uni.showLoading({
				    title: '加载中'
				});
				http.post('/api/balance/addBalance',{bankType:this.bankCode,bankCode:this.kaNum}).then(res => {
					if (res.code == 200) {
						uni.navigateBack({
							url:'/pages/bank/bankList'
						})
					}
					uni.hideLoading();
				})
				
			}
		}
	}
</script>

<style>
	page{
		
	}
	.inp{
		width: 84%;
		padding: 2vw 4vw;
		border-radius: 1vw;
		background: #f9f9f9;
		font-size: 3.8vw;
		color: #333333;
		margin: 0 auto;
		border: 1px solid #f2f2f2;
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		align-items: center;
		margin-top: 4vw;
	}
	.inputList{
		padding: 0 4vw;
		margin-bottom: 6vw;
	}
	.inputList .title{
		margin-bottom: 2vw;
		font-size: 3.6vw;
		color: #999999;
	}
	.inputList input,.inputList .uni-input{
		border-radius: 1vw;
		background: #f9f9f9;
		font-size: 3.8vw;
		height: 10vw;
		line-height: 10vw;
		text-indent: 2vw;
	}
	.title span{
		color: #007AFF;
		margin-left: 4vw;
	}
	.btn{
		width: 84%;
		padding: 4vw 0;
		font-size: 3.5vw;
		border-radius: 1.8vw;
		background-image: linear-gradient(45deg, #24EBA9, #10C7B2);
		color: #FFFFFF;
		text-align: center;
		margin: 0 auto;
		margin-top: 10vw;
	}
</style>
